//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "YearOnYearInflationSwap.h"
using namespace Cephei::QL::Instruments;
#include <gen/QL/Times/DayCounter.h>
#include <gen/QL/CashFlow.h>
#include <gen/QL/Times/Schedule.h>
#include <gen/QL/Times/Period.h>
#include <gen/QL/Times/Calendar.h>
#include <gen/QL/Indexes/YoYInflationIndex.h>
#include <gen/QL/PricingEngine.h>
#include <gen/QL/Instruments/Swap.h>
using namespace Cephei::QL::Times;
using namespace Cephei::QL;
using namespace Cephei::QL::Indexes;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Instruments::CYearOnYearInflationSwap::CYearOnYearInflationSwap (QL::Instruments::YearOnYearInflationSwap::TypeEnum type, Double nominal, Cephei::QL::Times::ISchedule^ fixedSchedule, Double fixedRate, Cephei::QL::Times::IDayCounter^ fixedDayCount, Cephei::QL::Times::ISchedule^ yoySchedule, Cephei::QL::Indexes::IYoYInflationIndex^ yoyIndex, Cephei::QL::Times::IPeriod^ observationLag, Double spread, Cephei::QL::Times::IDayCounter^ yoyDayCount, Cephei::QL::Times::ICalendar^ paymentCalendar, Microsoft::FSharp::Core::FSharpOption<QL::Times::BusinessDayConventionEnum>^ paymentConvention, Cephei::QL::IPricingEngine^ QL_Pricer) : CSwap(CYearOnYearInflationSwap::typeid)
{
    CSchedule^ _CfixedSchedule;
    CDayCounter^ _CfixedDayCount;
    CSchedule^ _CyoySchedule;
    CYoYInflationIndex^ _CyoyIndex;
    CPeriod^ _CobservationLag;
    CDayCounter^ _CyoyDayCount;
    CCalendar^ _CpaymentCalendar;
    try
    {
#ifdef HANDLE
        _phYearOnYearInflationSwap = NULL;
#endif
        QuantLib::YearOnYearInflationSwap::Type _type = (QuantLib::YearOnYearInflationSwap::Type)type ;
        QuantLib::Real _nominal = (QuantLib::Real)ValueHelper::Convert (nominal); //d
        _CfixedSchedule = safe_cast<CSchedule^> (fixedSchedule);
        _CfixedSchedule->Lock();
        QuantLib::Schedule& _fixedSchedule = static_cast<QuantLib::Schedule&> (_CfixedSchedule->GetReference ()); 
        QuantLib::Rate _fixedRate = (QuantLib::Rate)ValueHelper::Convert (fixedRate); //d
        _CfixedDayCount = safe_cast<CDayCounter^> (fixedDayCount);
        _CfixedDayCount->Lock();
        QuantLib::DayCounter& _fixedDayCount = static_cast<QuantLib::DayCounter&> (_CfixedDayCount->GetReference ()); 
        _CyoySchedule = safe_cast<CSchedule^> (yoySchedule);
        _CyoySchedule->Lock();
        QuantLib::Schedule& _yoySchedule = static_cast<QuantLib::Schedule&> (_CyoySchedule->GetReference ()); 
        _CyoyIndex = safe_cast<CYoYInflationIndex^> (yoyIndex);
        _CyoyIndex->Lock();
        boost::shared_ptr<QuantLib::YoYInflationIndex>& _yoyIndex = static_cast<boost::shared_ptr<QuantLib::YoYInflationIndex>&> (_CyoyIndex->GetShared ()); 
        _CobservationLag = safe_cast<CPeriod^> (observationLag);
        _CobservationLag->Lock();
        QuantLib::Period& _observationLag = static_cast<QuantLib::Period&> (_CobservationLag->GetReference ()); 
        QuantLib::Spread _spread = (QuantLib::Spread)ValueHelper::Convert (spread); //d
        _CyoyDayCount = safe_cast<CDayCounter^> (yoyDayCount);
        _CyoyDayCount->Lock();
        QuantLib::DayCounter& _yoyDayCount = static_cast<QuantLib::DayCounter&> (_CyoyDayCount->GetReference ()); 
        _CpaymentCalendar = safe_cast<CCalendar^> (paymentCalendar);
        _CpaymentCalendar->Lock();
        QuantLib::Calendar& _paymentCalendar = static_cast<QuantLib::Calendar&> (_CpaymentCalendar->GetReference ()); 
        QuantLib::BusinessDayConvention _paymentConvention = 
            (Microsoft::FSharp::Core::FSharpOption<QL::Times::BusinessDayConventionEnum>::IsSome::get (paymentConvention) ? (QuantLib::BusinessDayConvention)paymentConvention->Value : QuantLib::BusinessDayConvention::ModifiedFollowing); //10
        _ppYearOnYearInflationSwap = new boost::shared_ptr<QuantLib::YearOnYearInflationSwap> (new QuantLib::YearOnYearInflationSwap ( _type,  _nominal,  _fixedSchedule,  _fixedRate,  _fixedDayCount,  _yoySchedule,  _yoyIndex,  _observationLag,  _spread,  _yoyDayCount,  _paymentCalendar,  _paymentConvention ));
        CPricingEngine^ _CQL_Pricer = safe_cast<CPricingEngine^> (QL_Pricer);
        boost::shared_ptr<QuantLib::PricingEngine>& _QL_Pricer = static_cast<boost::shared_ptr<QuantLib::PricingEngine>&> (_CQL_Pricer->GetShared ());
        (*_ppYearOnYearInflationSwap)->setPricingEngine (_QL_Pricer);
        SetSwap (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppYearOnYearInflationSwap));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_CfixedSchedule != nullptr) _CfixedSchedule->Unlock();
        if (_CfixedDayCount != nullptr) _CfixedDayCount->Unlock();
        if (_CyoySchedule != nullptr) _CyoySchedule->Unlock();
        if (_CyoyIndex != nullptr) _CyoyIndex->Unlock();
        if (_CobservationLag != nullptr) _CobservationLag->Unlock();
        if (_CyoyDayCount != nullptr) _CyoyDayCount->Unlock();
        if (_CpaymentCalendar != nullptr) _CpaymentCalendar->Unlock();
    }
}
Cephei::QL::Instruments::CYearOnYearInflationSwap::CYearOnYearInflationSwap (boost::shared_ptr<QuantLib::YearOnYearInflationSwap>& childNative, Object^ owner) : CSwap(CYearOnYearInflationSwap::typeid)
{
#ifdef HANDLE
	_phYearOnYearInflationSwap = NULL;
#endif
	_ppYearOnYearInflationSwap = &childNative;
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppYearOnYearInflationSwap));
}
Cephei::QL::Instruments::CYearOnYearInflationSwap::CYearOnYearInflationSwap (QuantLib::YearOnYearInflationSwap& childNative, Object^ owner) : CSwap(CYearOnYearInflationSwap::typeid)
{
#ifdef HANDLE
	_phYearOnYearInflationSwap = NULL;
#endif
	_ppYearOnYearInflationSwap = new boost::shared_ptr<QuantLib::YearOnYearInflationSwap> (&childNative);
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppYearOnYearInflationSwap));
    _YearOnYearInflationSwapOwner = owner;
    _SwapOwner = owner;
}

Cephei::QL::Instruments::CYearOnYearInflationSwap::CYearOnYearInflationSwap (CYearOnYearInflationSwap^ copy) : CSwap(CYearOnYearInflationSwap::typeid)
{
#ifdef HANDLE
	_phYearOnYearInflationSwap = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppYearOnYearInflationSwap = new boost::shared_ptr<QuantLib::YearOnYearInflationSwap> (copy->GetShared());
        _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppYearOnYearInflationSwap));
    }
}
Cephei::QL::Instruments::CYearOnYearInflationSwap::CYearOnYearInflationSwap (PLATFORM::Type^ t) : CSwap(CYearOnYearInflationSwap::typeid)
{
#ifdef HANDLE
	_phYearOnYearInflationSwap = NULL;
#endif
	if (!t->IsSubclassOf(CYearOnYearInflationSwap::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Instruments::CYearOnYearInflationSwap::CYearOnYearInflationSwap (QuantLib::Handle<QuantLib::YearOnYearInflationSwap>& childNative, Object^ owner)  : CSwap(CYearOnYearInflationSwap::typeid)
{
	_phYearOnYearInflationSwap = &childNative;
	_ppYearOnYearInflationSwap = &static_cast<boost::shared_ptr<QuantLib::YearOnYearInflationSwap>>(childNative.currentLink());
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppYearOnYearInflationSwap));
    _YearOnYearInflationSwapOwner = owner;
}
Cephei::QL::Instruments::CYearOnYearInflationSwap::CYearOnYearInflationSwap (QuantLib::Handle<QuantLib::YearOnYearInflationSwap> childNative)  : CSwap(CYearOnYearInflationSwap::typeid)
{
	_phYearOnYearInflationSwap = &childNative;
	_ppYearOnYearInflationSwap = &static_cast<boost::shared_ptr<QuantLib::YearOnYearInflationSwap>>(childNative.currentLink());
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppYearOnYearInflationSwap));
}
#endif
#ifdef STRUCT
Cephei::QL::Instruments::CYearOnYearInflationSwap::CYearOnYearInflationSwap (QuantLib::YearOnYearInflationSwap childNative)  : CSwap(CYearOnYearInflationSwap::typeid)
{
#ifdef HANDLE
	_phYearOnYearInflationSwap = NULL;
#endif
	_ppYearOnYearInflationSwap = new boost::shared_ptr<QuantLib::YearOnYearInflationSwap> (new QuantLib::YearOnYearInflationSwap (childNative));
    _ppSwap = new boost::shared_ptr<QuantLib::Swap> (boost::dynamic_pointer_cast<QuantLib::Swap> (*_ppYearOnYearInflationSwap));
}
#endif

Cephei::QL::Instruments::CYearOnYearInflationSwap::~CYearOnYearInflationSwap ()
{
    if (_ppYearOnYearInflationSwap != NULL)
    {
	    delete _ppYearOnYearInflationSwap;
        _ppYearOnYearInflationSwap = NULL;
    }
}
Cephei::QL::Instruments::CYearOnYearInflationSwap::!CYearOnYearInflationSwap ()
{
    if (_ppYearOnYearInflationSwap != NULL)
    {
	    delete _ppYearOnYearInflationSwap;
    }
}
QuantLib::YearOnYearInflationSwap& Cephei::QL::Instruments::CYearOnYearInflationSwap::GetReference ()
{
    if (_ppYearOnYearInflationSwap == NULL) throw REFNEW NativeNullException ();
	return **_ppYearOnYearInflationSwap;
}
boost::shared_ptr<QuantLib::YearOnYearInflationSwap>& Cephei::QL::Instruments::CYearOnYearInflationSwap::GetShared ()
{
    if (_ppYearOnYearInflationSwap == NULL) throw REFNEW NativeNullException ();
	return *_ppYearOnYearInflationSwap;
}
QuantLib::YearOnYearInflationSwap* Cephei::QL::Instruments::CYearOnYearInflationSwap::GetPointer ()
{
    if (_ppYearOnYearInflationSwap == NULL) throw REFNEW NativeNullException ();
	return &**_ppYearOnYearInflationSwap;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::YearOnYearInflationSwap>& Cephei::QL::Instruments::CYearOnYearInflationSwap::GetHandle ()
{
	if (_phYearOnYearInflationSwap == NULL)
	{
		_phYearOnYearInflationSwap = new Handle<QuantLib::YearOnYearInflationSwap> (*_ppYearOnYearInflationSwap);
	}
	return *_phYearOnYearInflationSwap;
}
#endif
bool Cephei::QL::Instruments::CYearOnYearInflationSwap::HasNative () 
{
	return (_ppYearOnYearInflationSwap != NULL);
}

Double Cephei::QL::Instruments::CYearOnYearInflationSwap::FairRate::get ()
{
    try
    {
    	QuantLib::Rate _rv = (QuantLib::Rate)(*_ppYearOnYearInflationSwap)->fairRate ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::CYearOnYearInflationSwap::FixedRate::get ()
{
    try
    {
    	QuantLib::Rate _rv = (QuantLib::Rate)(*_ppYearOnYearInflationSwap)->fixedRate ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::CYearOnYearInflationSwap::FairSpread::get ()
{
    try
    {
    	QuantLib::Spread _rv = (QuantLib::Spread)(*_ppYearOnYearInflationSwap)->fairSpread ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::IDayCounter^ Cephei::QL::Instruments::CYearOnYearInflationSwap::FixedDayCount::get ()
{
    try
    {
    	QuantLib::DayCounter& _rv = (QuantLib::DayCounter&)(*_ppYearOnYearInflationSwap)->fixedDayCount ( );   
        Cephei::QL::Times::CDayCounter^ _nrv = REFNEW Cephei::QL::Times::CDayCounter (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::Core::IVector<Cephei::QL::ICashFlow^>^ Cephei::QL::Instruments::CYearOnYearInflationSwap::FixedLeg::get ()
{
    try
    {
    	std::vector<boost::shared_ptr<QuantLib::CashFlow> >& _rv = (std::vector<boost::shared_ptr<QuantLib::CashFlow> >&)(*_ppYearOnYearInflationSwap)->fixedLeg ( );   
        CoVector<Cephei::QL::ICashFlow^>^ _nrv = REFNEW CoVector<Cephei::QL::ICashFlow^>(REFNEW CCashFlowVector (_rv, this));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::CYearOnYearInflationSwap::FixedLegNPV::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppYearOnYearInflationSwap)->fixedLegNPV ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::ISchedule^ Cephei::QL::Instruments::CYearOnYearInflationSwap::FixedSchedule::get ()
{
    try
    {
    	QuantLib::Schedule& _rv = (QuantLib::Schedule&)(*_ppYearOnYearInflationSwap)->fixedSchedule ( );   
        Cephei::QL::Times::CSchedule^ _nrv = REFNEW Cephei::QL::Times::CSchedule (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::CYearOnYearInflationSwap::Nominal::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppYearOnYearInflationSwap)->nominal ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::IPeriod^ Cephei::QL::Instruments::CYearOnYearInflationSwap::ObservationLag::get ()
{
    try
    {
    	QuantLib::Period _rv = (QuantLib::Period)(*_ppYearOnYearInflationSwap)->observationLag ( );   
        Cephei::QL::Times::CPeriod^ _nrv = REFNEW Cephei::QL::Times::CPeriod (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::ICalendar^ Cephei::QL::Instruments::CYearOnYearInflationSwap::PaymentCalendar::get ()
{
    try
    {
    	QuantLib::Calendar _rv = (QuantLib::Calendar)(*_ppYearOnYearInflationSwap)->paymentCalendar ( );   
        Cephei::QL::Times::CCalendar^ _nrv = REFNEW Cephei::QL::Times::CCalendar (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
QL::Times::BusinessDayConventionEnum Cephei::QL::Instruments::CYearOnYearInflationSwap::PaymentConvention::get ()
{
    try
    {
    	QuantLib::BusinessDayConvention _rv = (QuantLib::BusinessDayConvention)(*_ppYearOnYearInflationSwap)->paymentConvention ( );   
        QL::Times::BusinessDayConventionEnum _nrv = (QL::Times::BusinessDayConventionEnum)_rv;
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::CYearOnYearInflationSwap::Spread::get ()
{
    try
    {
    	QuantLib::Spread _rv = (QuantLib::Spread)(*_ppYearOnYearInflationSwap)->spread ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
QL::Instruments::YearOnYearInflationSwap::TypeEnum Cephei::QL::Instruments::CYearOnYearInflationSwap::Type::get ()
{
    try
    {
    	QuantLib::YearOnYearInflationSwap::Type _rv = (QuantLib::YearOnYearInflationSwap::Type)(*_ppYearOnYearInflationSwap)->type ( );   
        QL::Instruments::YearOnYearInflationSwap::TypeEnum _nrv = (QL::Instruments::YearOnYearInflationSwap::TypeEnum)_rv;
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::IDayCounter^ Cephei::QL::Instruments::CYearOnYearInflationSwap::YoyDayCount::get ()
{
    try
    {
    	QuantLib::DayCounter& _rv = (QuantLib::DayCounter&)(*_ppYearOnYearInflationSwap)->yoyDayCount ( );   
        Cephei::QL::Times::CDayCounter^ _nrv = REFNEW Cephei::QL::Times::CDayCounter (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Indexes::IYoYInflationIndex^ Cephei::QL::Instruments::CYearOnYearInflationSwap::YoyInflationIndex::get ()
{
    try
    {
    	boost::shared_ptr<QuantLib::YoYInflationIndex>& _rv = (boost::shared_ptr<QuantLib::YoYInflationIndex>&)(*_ppYearOnYearInflationSwap)->yoyInflationIndex ( );   
        Cephei::QL::Indexes::CYoYInflationIndex^ _nrv = REFNEW Cephei::QL::Indexes::CYoYInflationIndex (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::Core::IVector<Cephei::QL::ICashFlow^>^ Cephei::QL::Instruments::CYearOnYearInflationSwap::YoyLeg::get ()
{
    try
    {
    	std::vector<boost::shared_ptr<QuantLib::CashFlow> >& _rv = (std::vector<boost::shared_ptr<QuantLib::CashFlow> >&)(*_ppYearOnYearInflationSwap)->yoyLeg ( );   
        CoVector<Cephei::QL::ICashFlow^>^ _nrv = REFNEW CoVector<Cephei::QL::ICashFlow^>(REFNEW CCashFlowVector (_rv, this));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::CYearOnYearInflationSwap::YoyLegNPV::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppYearOnYearInflationSwap)->yoyLegNPV ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::ISchedule^ Cephei::QL::Instruments::CYearOnYearInflationSwap::YoySchedule::get ()
{
    try
    {
    	QuantLib::Schedule& _rv = (QuantLib::Schedule&)(*_ppYearOnYearInflationSwap)->yoySchedule ( );   
        Cephei::QL::Times::CSchedule^ _nrv = REFNEW Cephei::QL::Times::CSchedule (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Instruments::IYearOnYearInflationSwap^ Cephei::QL::Instruments::CYearOnYearInflationSwap_Factory::Create (QL::Instruments::YearOnYearInflationSwap::TypeEnum type, Double nominal, Cephei::QL::Times::ISchedule^ fixedSchedule, Double fixedRate, Cephei::QL::Times::IDayCounter^ fixedDayCount, Cephei::QL::Times::ISchedule^ yoySchedule, Cephei::QL::Indexes::IYoYInflationIndex^ yoyIndex, Cephei::QL::Times::IPeriod^ observationLag, Double spread, Cephei::QL::Times::IDayCounter^ yoyDayCount, Cephei::QL::Times::ICalendar^ paymentCalendar, Microsoft::FSharp::Core::FSharpOption<QL::Times::BusinessDayConventionEnum>^ paymentConvention, Cephei::QL::IPricingEngine^ QL_Pricer)
{
    return REFNEW CYearOnYearInflationSwap ( type,  nominal,  fixedSchedule,  fixedRate,  fixedDayCount,  yoySchedule,  yoyIndex,  observationLag,  spread,  yoyDayCount,  paymentCalendar,  paymentConvention,  QL_Pricer);
}
